package form

import "github.com/pkg/errors"

// 订单表单
type OrderForm struct {
	Id        uint    `form:"id" json:"order_no"`                              //主键
	OrderNo   string  `form:"order_no" json:"order_no"`                        //单号
	UserId    uint    `form:"user_id" json:"user_id" binding:"required"`       //客户id
	UserName  string  `form:"user_name" json:"user_name" binding:"required"`   //客户姓名
	UserPhone string  `form:"user_phone" json:"user_phone" binding:"required"` //客户手机号
	Price     float32 `form:"price" json:"price" binding:"required"`           //价格
}

// 进行参数合法性验证
func (this OrderForm) Validate() (bool, error) {
	if len(this.UserPhone) != 11 {

		return false, errors.New("手机号码为11位")
	}

	return true, nil
}
